var Member = {};

Member.checkPassword = function(){
	if($('#pwd_new').val()!=$('#pwd_ck').val()){
		$('#errorMsg').text('两次输入的密码不一致！\n请重新输入');
		$('#errorMsg').css("color",'red');
		$('#pwd_new').val('');
		$('#pwd_ck').val('');
		return false;
	}
}

Member.checkLoginName = function(){
	if($('#loginName').val()==''){
		alert("未输入用户名！");
		return false;
	}
	$.ajax({
		type:"POST",
		url:context+'/front/member!checkLoginName.action', 
		data:{
			'loginName':$('#loginName').val()
		},
		success:function(text){
			if(text!='true'){
				$('#errorMsg').text(text);
				$('#erroeMsg').css("color",'red');
				$('#loginName').val('');
				return false;
			}else{
				$('#errorMsg').text("用户名可用！");
				$('#errorMsg').css("color",'green');
			}
		}
	});
}

Member.apply = function(){
	if(!util.checkFormFields($('#registerform'))){
		alert("请按提示输入合法内容，或完成必填项！");
		return false;
	}
	Member.checkPassword();
	Member.checkLoginName();
	$.ajax({
		type:"POST",
		url:context+'/front/member!sureApply.action?'+$('#registerform').serialize(), 
		success:function(text){
			alert(text);
		}
	})
}

Member.login = function(){
	if(!util.checkFormFields($('#loginFrom'))){
		alert("请按提示输入合法内容，或完成必填项！");
		return false;
	}
	$.ajax({
		type:"POST",
		url:context+'/front/member!checkUser.action?'+$('#loginFrom').serialize(), 
		success:function(text){
			if(text=='success'){
				location.href = context+'/login.action';
			}else{
				$('#errorMsg').text(text);
				$('#errorMsg').css("color",'red');
			}
		}
	})
}